package com.labichaoka.chaoka.ui.home.fragment.my.feedback;

import com.labichaoka.chaoka.entity.BaseResponse;
import com.labichaoka.chaoka.entity.FeedBackRequest;

/**
 * Created by ruan on 2018/8/9.
 */

public class FeedBackPresenterImpl implements FeedBackPresenter,FeedBackInteractor.OnFeedBackFinishedListener {
    private FeedBackInteractor feedBackInteractor;
    private FeedBackView feedBackView;

    public FeedBackPresenterImpl(FeedBackInteractor feedBackInteractor, FeedBackView feedBackView) {
        this.feedBackInteractor = feedBackInteractor;
        this.feedBackView = feedBackView;
    }

    @Override
    public void commitFeedBack(FeedBackRequest request) {
        if (feedBackView!=null){
            feedBackView.showProgress();
        }
        feedBackInteractor.commitFeedBack(request,this);
    }

    @Override
    public void onDestroy() {
        feedBackView=null;
    }

    @Override
    public void onSuccessed(BaseResponse response) {
        feedBackView.hideProgress();
        feedBackView.showMessage(response.getMessage());
        feedBackView.commitSuccess();
    }

    @Override
    public void onFailed() {
        feedBackView.hideProgress();
    }
}
